<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
   {include="style"}

  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a >首页</a>
        <a >权限管理</a>
        <a><cite>权限列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="iconfont" style="line-height:30px">&#xe6aa;</i></a>
    </div>
    <div class="x-body">
		<div class="layui-card">
			<div class="layui-card-body">
			<form  method="post" class="layui-form layui-form-pane">
				 <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">
                        栏目选择 
                    </label>
                    <table  class="layui-table layui-input-block">
                        <tbody>
							<tr>
                                <th>
                                   顶级栏目
                                </th>
                                <th>
                                   子栏目
                                </th>
                            </tr>
						{foreach $classtypetree as $v}
						{if($v['pid']==0)}
                            <tr>
                                <td>
                                    <input type="checkbox" name="ruler[]" lay-skin="primary" value="class_{$v['id']}" title="{$v['classname']}" >
                                </td>
                                <td>
                                    <div class="layui-input-block">
                                    {php $children = get_children($v,$classtypetree,5);/}
									{foreach $children as $vv}
                                        <input name="ruler[]" lay-skin="primary" type="checkbox" title="{$vv['classname']}" value="class_{$vv['id']}" > 
									{/foreach}
                                        
                                    </div>
                                </td>
                            </tr>
                        {/if}
						{/foreach}
                           
                        </tbody>
                    </table>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">
                        权限选择  <span class="x-red">不能选择的权限是非独立功能</span>
                    </label>
                    <table  class="layui-table layui-input-block">
                        <tbody>
							<tr>
                                <th>
                                   主模块
                                </th>
                                <th>
                                   子模块
                                
                                </th>
                            </tr>
						{foreach $ruler_top as $v}
                            <tr>
                                <td style="width:100px">
                                    {$v['name']}
                                </td>
                                <td>
                                    <div class="layui-input-block">
									{foreach $ruler_children[$v['id']] as $vv}
										
                                        <input name="ruler[]" {if($vv['isdesktop']!=1)}disabled{/if} lay-skin="primary" type="checkbox" title="{$vv['name']}" value="{$vv['id']}" > 
										
									{/foreach}
                                        
                                    </div>
                                </td>
                            </tr>
						{/foreach}
                           
                        </tbody>
                    </table>
                </div>
				<div class="layui-form-item" style="text-align:center;">
                <button class="layui-btn" lay-submit="" lay-filter="add">添加</button>
				</div>
	
			</div>
		</form>
			
			</div>
		</div>
     
  
    <script>
	layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
		  
		  form.render();
          //监听提交
          form.on('submit(add)', function(data){
           
			//var ruler = JSON.stringify(data.field);
			var ruler = [];
			for( item in data.field){
				ruler.push(data.field[item])
			}
			if(ruler.length==0){
				layer.alert('请先勾选菜单!');
				return false;
			}
			window.parent.setNavChildren(ruler.join(','));
			window.parent.closeiframe();
			
            return false;
          });
	   
      });
	

     
		
			
    
    </script>
    
  </body>

</html>